home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / disp182a.zip / DRVSRC / ATIVGA.ASM < prev    next >
Assembly Source File  |  1993-12-06  |  12KB  |  399 lines

  1. ;--------------------------------------------------------------------------
  2. ; This is file ATIVGA.ASM
  3. ;
  4. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  5. ; Copyright (C) 1992 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221
  6. ;
  7. ; This file is distributed under the terms listed in the document
  8. ; "copying.dj", available from DJ Delorie at the address above.
  9. ; A copy of "copying.dj" should accompany this file; if not, a copy
  10. ; should be available from where this file was obtained.  This file
  11. ; may not be distributed without a verbatim copy of "copying.dj".
  12. ;
  13. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  14. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. ;--------------------------------------------------------------------------
  16.  
  17. include grdriver.inc
  18. cseg    segment byte public 'code'
  19.     assume  cs:cseg, ds:cseg, es:cseg, ss:nothing
  20.  
  21.  
  22. ;--------------------------------------------------------------------------
  23. ; DRIVER HEADER
  24. ;  The following entries MUST match the structure and constant
  25. ;  declarations in the file 'grdriver.h' of the GRX graphics library
  26. ;  The mode word should contain the following bitfields:
  27. ;     - the GRD_NEW_DRIVER bit set for any new format driver
  28. ;     - the adapter type field should be specified
  29. ;     - the memory size field should be specified
  30. ;     - the paging mode field should be specified
  31. ;  The mode set routine will OR in the plane bitfield as it will
  32. ;  change when different color number modes are requested.
  33. ;--------------------------------------------------------------------------
  34.  
  35.     dw    offset mode_set_routine
  36.     dw    offset paging_routine
  37. mode_W  dw    GRD_NEW_DRIVER+GRD_VGA+GRD_256K+GRD_RW_64K
  38. ;
  39. ; The 'def_xx' fields are filled in by go32 from the corresponding
  40. ; fields of the 'GO32' environment variable
  41. ;
  42. def_tw  dw    80        ; text width
  43. def_th  dw    25        ; text height
  44. def_gw  dw    640        ; graphics width
  45. def_gh  dw    480        ; graphics height
  46. def_nc  dw    16        ; graphics colors
  47.     dw    offset driver_init_routine
  48.     dw    offset text_mode_table
  49.     dw    offset graphics_mode_table
  50.  
  51. ;
  52. ; Biggest text and graphics sizes
  53. ;
  54. Max_TW  equ    80
  55. Max_TH  equ    50
  56. Max_GWn equ    800        ; non interlaced!!!
  57. Max_GHn equ    600
  58. Max_GW  equ    1024        ; may be interlaced
  59. Max_GH  equ    768
  60.  
  61.  
  62. ;--------------------------------------------------------------------------
  63. ; TABLE OF SUPPORTED TEXT MODES
  64. ;    - keep sorted by size
  65. ;    - end with an all 0 entry
  66. ;    - BIOS field = 0xff disables it
  67. ;    - fields:
  68. ;        width,  height, colors, BIOS#+  setup_procedure_index*256
  69. ;--------------------------------------------------------------------------
  70. text_mode_table        label word
  71.     dw    80,    25,    2,    007h +  00000h
  72.     dw    40,    25,    16,    001h +  00000h
  73.     dw    80,    25,    16,    003h +  00000h
  74.     dw    80,    28,    16,    003h +  00100h
  75.     dw    80,    50,    16,    003h +  00200h
  76.     dw    132,    25,    16,    023h +  00000h
  77.     dw    132,    28,    16,    023h +  00100h
  78.     dw    132,    44,    16,    033h +  00000h
  79.     dw    0,    0,    0,    000h +  00000h
  80.  
  81. ;--------------------------------------------------------------------------
  82. ; TABLE OF SUPPORTED GRAPHICS MODES
  83. ;    - keep sorted first by colors then by size
  84. ;    - end with an all 0 entry
  85. ;    - BIOS field = 0xff disables it
  86. ;    - fields:
  87. ;        width,  height, colors, BIOS#+  setup_procedure_index*256
  88. ;--------------------------------------------------------------------------
  89. graphics_mode_table    label word
  90.     dw    320,    200,    16,    00dh +  00000h
  91.     dw    640,    200,    16,    00eh +  00000h
  92.     dw    640,    350,    16,    010h +  00000h
  93.     dw    640,    480,    16,    012h +  00000h
  94.     dw    800,    600,    16,    054h +  00000h
  95.     dw    1024,    768,    16,    055h +  00000h
  96.     dw    320,    200,    256,    013h +  00000h
  97.     dw    640,    400,    256,    061h +  00000h
  98.     dw    640,    480,    256,    062h +  00000h
  99. ;    dw    800,    600,    256,    063h +  00000h
  100.     dw    0,    0,    0,    000h +  00000h
  101.  
  102. ;--------------------------------------------------------------------------
  103. ; TABLE OF SPECIAL SETUP PROCEDURES
  104. ;  You may need such procedures for:
  105. ;     -- reloading fonts on standard EGA or VGA for
  106. ;     higher resolution text modes
  107. ;     -- enable HiColor mode of some Super VGAs
  108. ;     -- Handle the parameter passing conventions of the VESA BIOS
  109. ;     -- put VGA into 256 color plane mode ("MODE X")
  110. ;     -- etc...
  111. ;  There should be one entry in the table for every non-zero
  112. ;  'setup_procedure_index' in the text and graphics mode tables.
  113. ;  The first entry in the table belongs to index 100h, and so on.
  114. ;  The special setup procedure is invoked via a near call.
  115. ;
  116. ;  Entry: DI=address of the mode record from the text or graphics
  117. ;      table to set up.
  118. ;
  119. ;  Exit:  Adapter configured
  120. ;      BX=driver mode word as it should be returned by the mode set
  121. ;         routine. Typically it involves picking up the mode word
  122. ;         from the header and OR-ing in the appropriate bitplane mode
  123. ;         bitfield. (This is not needed for text modes)
  124. ;      AX, CX, DX, SI can be trashed, PRESERVE DI!!!!
  125. ;
  126. ;  NOTE: This runs in real mode, but don't mess with the segment registers.
  127. ;--------------------------------------------------------------------------
  128. special_setup_table    label word
  129.     dw    offset  VGA_28row_mode_set
  130.     dw    offset  VGA_50row_mode_set
  131.     dw    offset  VGA_MODE_X_set
  132.  
  133. ;
  134. ; Routine to set up VGA 50 row mode
  135. ; interface is described above
  136. ;
  137. VGA_50row_mode_set    proc    near
  138.     mov    ax,03h            ; set 80x25 mode
  139.     int    10h
  140.     xor    bx,bx
  141.     mov    ax,1112h        ; load 8x8 font
  142.     int    10h
  143.     ret
  144. VGA_50row_mode_set    endp
  145.  
  146. VGA_28row_mode_set    proc    near
  147.     mov    ax,WORD PTR [di+6]    ; set 25 line mode
  148.     xor    ah,ah
  149.     int    10h
  150.     xor    bx,bx
  151.     mov    ax,1111h        ; load 8x14 font
  152.     int    10h
  153.     ret
  154. VGA_28row_mode_set    endp
  155.  
  156. ;
  157. ; Routine to set up VGA 256 color plane mode ("MODE X")
  158. ; interface is described above
  159. ; TO BE COMPLETED
  160. ;
  161. VGA_MODE_X_set        proc    near
  162.     mov    bx,mode_W
  163.     or    bx,GRD_8_X_PLANES
  164.     ret
  165. VGA_MODE_X_set        endp
  166.  
  167.  
  168. ;--------------------------------------------------------------------------
  169. ; DRIVER INIT ROUTINE
  170. ;  called once after the driver is loaded
  171. ;  may do one or more of the followings:
  172. ;    - check for proper board type
  173. ;    - check amount of RAM on board, and:
  174. ;    -- update word in header to reflect correct amount
  175. ;    -- disable modes in the tables for which there is not enough RAM
  176. ;    - check for special equipment (HiColor DAC, etc...)
  177. ;
  178. ;  Entry: nothing
  179. ;
  180. ;  Exit:  AX=status:
  181. ;       non-zero: OK,
  182. ;       0: something went wrong (e.g. wrong adapter, etc..)
  183. ;      BX,CX,DX may be trashed
  184. ;
  185. ;  NOTE: This runs in real mode, but don't mess with the segment registers.
  186. ;--------------------------------------------------------------------------
  187. driver_init_routine    proc    far
  188.     mov    ax,1
  189.     ret
  190. driver_init_routine    endp
  191.  
  192.  
  193. ;--------------------------------------------------------------------------
  194. ; MODE SET ROUTINE
  195. ;  sets up a text or graphics mode as close as possible to the one
  196. ;  reguested by the user with regard to number of colors and size.
  197. ;
  198. ;  Entry: AX=mode selection
  199. ;     0 = 80x25 text
  200. ;     1 = default text
  201. ;     2 = text CX cols by DX rows
  202. ;     3 = biggest text
  203. ;     4 = 320x200 graphics
  204. ;     5 = default graphics
  205. ;     6 = graphics CX width by DX height
  206. ;     7 = biggest non-interlaced graphics
  207. ;     8 = biggest graphics
  208. ;     9 = graphics BX colors, CX width by DX height
  209. ;
  210. ;  Exit: BX=driver mode flag
  211. ;     CX=width (in pixels or characters)
  212. ;     DX=height
  213. ;
  214. ;  NOTE: This runs in real mode, but don't mess with the segment registers.
  215. ;     YOU SHOULD NOT NEED TO CHANGE THIS ROUTINE AS IT IS PRETTY
  216. ;     MUCH TABLE DRIVEN
  217. ;--------------------------------------------------------------------------
  218. mode_set_routine    proc    far
  219.     push    ds
  220.     push    di
  221.     push    si
  222.     mov    si,cs
  223.     mov    ds,si
  224.     cmp    ax,9
  225.     jbe    DoIt
  226.     jmp    Exit
  227. DoIt:    add    ax,ax
  228.     mov    si,ax
  229.     jmp    WORD PTR mode_set_table[si]
  230. mode_set_table  label    word
  231.     dw    offset mode_0
  232.     dw    offset mode_1
  233.     dw    offset mode_2
  234.     dw    offset mode_3
  235.     dw    offset mode_4
  236.     dw    offset mode_5
  237.     dw    offset mode_6
  238.     dw    offset mode_7
  239.     dw    offset mode_8
  240.     dw    offset mode_9
  241. mode_0: mov    si,offset text_mode_table    ; 80x25 text
  242.     mov    bx,def_nc
  243.     mov    cx,80
  244.     mov    dx,25
  245.     jmp    Lookup
  246. mode_1: mov    si,offset text_mode_table    ; default text
  247.     mov    bx,def_nc
  248.     mov    cx,def_tw
  249.     mov    dx,def_th
  250.     jmp    Lookup
  251. mode_2: mov    si,offset text_mode_table    ; CX